﻿namespace CSharpPro._10_09;

public class Demo
{
    public void Test1()//1000内水仙花
    {
        Console.WriteLine("1000以内的水仙花数有：");
        for (int i = 100; i < 1000; i++)  
        {
            int hundreds = i / 100;      
            int tens = (i / 10) % 10;     
            int units = i % 10;          
         
            int sum = hundreds * hundreds * hundreds + 
                      tens * tens * tens + 
                      units * units * units;
            
            if (sum == i)  
            {
                Console.Write(i + " ");
            }
        }
        Console.WriteLine("\n");

    }

    public void Test2()//100内质数
    {
        for (int num = 2; num <= 100; num++)  
        {
            bool isPrime = true;  
            for (int i = 2; i < num; i++)
            {
                if (num % i == 0)  
                {
                    isPrime = false;
                    break;  
                }
            }
            if (isPrime) 
            {
                Console.Write(num + " ");
            }
        }
        Console.WriteLine();
    }
        
    }





